package com.xjf.springboot001.controller;

import java.util.List;

import com.xjf.springboot001.entity.UserEntity;
import com.xjf.springboot001.mapper.UserXmlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class UserXmlController {

    @Autowired
    private UserXmlMapper userXmlMapper;

    @RequestMapping("/getUsersForXml")
    public List<UserEntity> getUsers() {
        List<UserEntity> users=userXmlMapper.getAll();
        return users;
    }

    @RequestMapping("/getUserForXml")
    public UserEntity getUser(Long id) {
        UserEntity user=userXmlMapper.getOne(id);
        return user;
    }

    @RequestMapping("/addForXml")
    public void save(UserEntity user) {
        userXmlMapper.insert(user);
    }

    @RequestMapping(value="updateForXml")
    public void update(UserEntity user) {
        userXmlMapper.update(user);
    }

    @RequestMapping(value="/deleteForXml/{id}")
    public void delete(@PathVariable("id") Long id) {
        userXmlMapper.delete(id);
    }


}